package com.rjh.spring.ioc;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

import java.applet.AppletContext;

public class IocTest {

    public static void main(String[] args) {
/*        Person person = null;
        Resource resource = new ClassPathResource("applicationContext.xml");
        BeanFactory factory = new XmlBeanFactory(resource);
        System.out.println(factory);
        person = (Person) factory.getBean("person");
        person.sayHello();
        System.out.println(person);*/

        ApplicationContext atx = new ClassPathXmlApplicationContext("applicationContext.xml");
        Person p2 = atx.getBean(Person.class);
        p2.sayHello();


        SomeBean2 s2 = atx.getBean(SomeBean2.class);

        SomeBean3 s3 = atx.getBean(SomeBean3.class);

        SomeBean4 s4 = atx.getBean(SomeBean4.class);

        Employee employee = atx.getBean(Employee.class);
        System.out.println(employee);


        CollectionBean collectionBean = atx.getBean(CollectionBean.class);
        System.out.println(collectionBean);


    }
}
